var url = window.location.pathname;
$("a[href='"+ url +"']").addClass('active');
var id = $("a[href='"+ url +"']").attr('data-target');
if (id != undefined) {
    $(id).collapse();
}
$("a[href='"+ url +"']").parents('ul.collapse').collapse();